﻿<div ng-controller="ClientManager_PaymentInfoC">
    <div class="bg-light lter b-b wrapper-md">
        <h1 class="m-n font-thin h3">新建报款</h1>
    </div>
    <div class="wrapper-md">
        <div class="panel panel-default">
            <div class="table-responsive">
                <form name="form" class="form-validation">
                    <div class="panel panel-default">
                        <div class="panel-body">
                            <!--<div class="form-group">-->
                            <!--<label class="control-label">客户</label>-->
                            <!--<input required type="text" disabled="true" class="form-control" ng-model="NowData.Customer.ShortName">-->
                            <!--</div>-->
                            <div class="form-group">
                                <label class="control-label">户头</label>
                                <!--<select class="form-control" ng-options="x.Id as x.Name for x in NowData.Customer.Accounts" ng-model="NowData.AccountId"></select>-->
                                <!--<input type="text" class="form-control" ng-model="NowData.Account.Name">-->
                                <input required type="text" disabled="true" class="form-control" ng-model="id.Name">
                            </div>
                            <div class="form-group">
                                <label class="control-label">金额</label>
                                <input required type="number" min="0" class="form-control" ng-model="NowData.Sum">
                            </div>
                            <div class="form-group">
                                <label class="control-label">报款时间</label>
                                <input required type="datetime" class=" form-control" ng-model="NowData.PaymentTime">
                            </div>
                            <div ng-if="id.IsCash" class="form-group">
                                <label class="control-label">备注(必填)</label>
                                <input required type="text" class="form-control" ng-model="NowData.Remark" placeholder="请输入打卡账户后四位">
                            </div>
                            <div ng-if="!id.IsCash" class="form-group">
                                <label class="control-label">备注(选填)</label>
                                <input type="text" class="form-control" ng-model="NowData.Remark" placeholder="请输入打卡账户后四位">
                            </div>
                            <div class="form-group">
                                <label>收款账户</label>
                                <select required class="form-control" ng-model="NowData.ToAccount">
                                    <option value="公-交行西苑路支行">公-交行西苑路支行</option>
                                    <option value="公-工行洛南支行">公-工行洛南支行</option>
                                    <option value="公-洛阳银行洛龙区支行">公-洛阳银行洛龙区支行</option>
                                    <option value="公-伊川农商行人民路支行">公-伊川农商行人民路支行</option>
                                    <option value="公-北京沐威中行">公-北京沐威中行</option>
                                    <option value="中国农业银行洛阳中泓支行">中国农业银行洛阳中泓支行</option>
                                    <option value="中国工商银行洛阳政和支行">中国工商银行洛阳政和支行</option>
                                    <option value="中国建设银行洛阳开元大道支行">中国建设银行洛阳开元大道支行</option>
                                    <option value="中国银行洛阳政和路支行">中国银行洛阳政和路支行</option>
                                    <option value="交通银行洛阳分行营业部">交通银行洛阳分行营业部</option>
                                    <option value="洛阳农商行金城寨街支行">洛阳农商行金城寨街支行</option>
                                    <option value="中信银行洛阳联盟路支行">中信银行洛阳联盟路支行</option>
                                    <option value="兴业银行洛阳凯旋东路支行">兴业银行洛阳凯旋东路支行</option>
                                </select>
                            </div>
                            <!--<div class="form-group">-->
                            <!--<label class="control-label">付款时间</label>-->
                            <!--<input required type="date" class="form-control" ng-model="NowData.CreateTime">-->
                            <!--</div>-->
                        </div>
                        <footer class="panel-footer text-right bg-light lter" style="text-align:center">
                            <button type="button" class="btn btn-success" ng-disabled="form.$invalid" ng-click="add()">新建</button>
                            <span style="padding:0 5%"></span>
                            <button type="button" class="btn btn-default" ng-click="goback()">取消</button>

                        </footer>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<script>
    angular.module('app')//非标优惠
.controller("ClientManager_PaymentInfoC", function ($scope, $state, $http, $stateParams) {
    $scope.id = JSON.parse($stateParams.id);
    $scope.NowData = {
        AccountId: $scope.id.Id,
        CreateTime: new Date(),
        PaymentTime: new Date()
    };

    $scope.goback = function () {
        $state.go('app.Customer_MyAccountList', { 'id': $scope.id.CustomerId, 'from': $stateParams.from });
        //if ($stateParams.from == "1") {
        //    $state.go('app.Customer_MyAccountList', { 'id': $scope.id.CustomerId, 'from': $stateParams.from });
        //}
        //if ($stateParams.from == "0") {
        //    $state.go('app.Customer_SelfList');
        //}
        };

        $scope.add = function () {
        $http.post("/api/ClientManager/ApplyPaymentInfo", $scope.NowData)
      .then(function (res) {
          if (res.State <= 0) {
              alert(res.Msg);
          } else {
              alert("提交成功");
              $state.go('app.ClientManager_PaymentInfoList');
          }
      }, function (error) {
          if (error) {
              alert("失败");
          }
      });
    };
})

</script>